<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      height: 300px;
      width: 300px;
      background-color: antiquewhite;
      position: relative;
    }

    .one {
      height: 200px;
      width: 200px;
      background-color: rgb(186, 241, 149);
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="one">
    </div>
  </div>
  <script>
    //JS中事件流的理解
    /*
      事件流:从页面中接收事件的顺序
      捕获-> 高->低
      冒泡-> 低->高
      document->html-body-div
      addEventListener(事件,回调函数,布尔值(false冒泡,true捕获))
    */
    let one = document.querySelector('.one')
    one.addEventListener('click', (e) => {
      e.stopPropagation()
      // e.preventDefault()阻止默认行为
      console.log('我是子元素');
    })
    let box = document.querySelector('.box')
    box.addEventListener('click', () => {
      console.log('我是父元素');
    })
  </script>
</body>

</html>